const Router = require('koa-router')  //注意：引入的方式
const { auth } = require('../middleware/auth.middleware')
const {menuValidator, hasMenu, menuIdValidator, menuIdHas} = require('../middleware/menu.middleware')
const {addMenu, editMenu, getMenuData, getMenuTree, delMenu} = require('../controller/menu.controller')

const router = new Router({ prefix: '/menu' })

// 新增菜单
router.post('/addMenu', auth, menuValidator, hasMenu, addMenu);
// 修改菜单
router.post('/editMenu', auth, menuIdValidator, editMenu);
// 删除
router.post('/delMenu', auth, menuIdValidator, menuIdHas, delMenu);

// 查询左侧菜单
router.post('/getLeftMenu', auth, getMenuData);

// 查询菜单树
router.post('/getMenuTree', auth, getMenuTree);

module.exports = router;